﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="adminQuestionClass.aspx.cs" Inherits="Admin_adminQuestionClass" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Src="adminfoot.ascx" TagName="adminfoot" TagPrefix="uc1" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link rel="stylesheet" href="imgs/admin.css" type="text/css" media="all" />
    <script type="text/javascript" src="../DotNet_net/js/jquery-1.3.2.min.js"></script>
     <script type="text/javascript" src="imgs/GetAjax.js"></script>
    <script type="text/javascript" src="../DotNet_net/js/common.js"></script>
</head>
<body onload="$('#loading').hide()">
  <form id="form1" runat="server">   
    <div class="container" id="cpcontainer">
<div id="loading" style="display:block">   
    <div class="loading-indicator">   
        页面正在加载中...   
    </div>   
</div> 
        
            <table class="tb2">
         <tr class="thead"><th colspan="7">问题管理(<font color='red'>＊</font>为必填,其它选填)</th></tr>	
        <tr align="center">
			<td align="left" width="20%">
                ID.问题类别名称(产品数量)</td>
			<td width="14%">类别名</td>
			<td width="10%">
                类别父id</td>
            <td width="16%">
                是否关联产品</td>
			<td width="13%">&nbsp;操作</td>		
        </tr>
        </table>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<table class="tb2">
<tbody>
<tr align="center"><td align="left" width="20%" id="qcf<%#Eval("QuestionClassID")%>" title="<%#Eval("QuestionFid") %>">&nbsp;<input  title="<%#Eval("QuestionFid") %>" type="checkbox" class="checkbox" value="<%#Eval("QuestionClassID") %>" name="m_id"><%#Eval("QuestionClassID") %>.<a href=""><%#Eval("QuestionClassName") %></a></td><td width="14%"><input type="text" value="<%#Eval("QuestionClassName") %>" name="qcname<%#Eval("QuestionClassID") %>" size="13"></td><td width="10%"><input type="text" value="<%#Eval("QuestionFid") %>" name="qcfid<%#Eval("QuestionClassID")%>" size="10"></td><td width="16%">
<input class="checkbox" disabled="disabled" type="checkbox" value="<%#Eval("QuestionClassID") %>"  <%#IsExistCheck(Eval("QuestionState"))%>  name="qs<%#Eval("QuestionClassID")%>" size="12"></td><input type="hidden" value="0" name=""><td width="13%"><input type="button" title="<%#Eval("QuestionClassID") %>" class="btn" name="Input" onclick="if(confirm('确定要删除吗')){$('#loading').show();ajax_get('?action=delAll&amp;id='+this.title,'',function(msg){if(msg=='1'){alert('该类下游子类无法删除，请先删除子类！');$('#loading').hide();}else{ $('#cpcontainer').empty().append(msg);$('#loading').hide();}});}else{return false}" value="删除"> </td></tr>
</tbody>
</table>
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<table class="tb2">
<tbody>
<tr align="center"><td align="left" width="20%" id="qcf<%#Eval("QuestionClassID")%>" title="<%#Eval("QuestionFid") %>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" title="<%#Eval("QuestionFid") %>" id="qcf<%#Eval("QuestionClassID") %>" class="checkbox" value="<%#Eval("QuestionClassID") %>" name="m_id"><%#Eval("QuestionClassID") %>.<a href="adminQuestion.aspx?qcid=<%#Eval("QuestionClassID") %>"><%#Eval("QuestionClassName") %></a>(<font color="red" id="count<%#Eval("QuestionClassID") %>"><%#getCountByID(Eval("QuestionClassID")) %></font>)</td><td width="14%"><input type="text" value="<%#Eval("QuestionClassName") %>" name="qcname<%#Eval("QuestionClassID") %>" size="13"></td><td width="10%"><input type="text" value="<%#Eval("QuestionFid") %>" name="qcfid<%#Eval("QuestionClassID") %>" size="10"></td><td width="16%">
<input class="checkbox" type="checkbox" value="<%#Eval("QuestionClassID") %>"  <%#IsExistCheck(Eval("QuestionState"))%>  name="qs<%#Eval("QuestionClassID") %>" size="12"></td><input type="hidden" value="0" name="pFid3"><td width="13%"><input type="button" title="<%#Eval("QuestionClassID") %>" class="btn" name="Input" onclick="if(confirm('确定要删除吗')){$('#loading').show();ajax_get('?action=delAll&amp;id='+this.title+'&amp;count='+$('#count<%#Eval("QuestionClassID") %>').text(),'',function(msg){if(msg=='1'){alert('该类下有子类无法删除，请先删除子类！');$('#loading').hide();}else if(msg=='2'){alert('该类下有问题，请先删除该类下的问题！');$('#loading').hide();}else{$('#cpcontainer').empty().append(msg);$('#loading').hide();}});}else{return false}" value="删除"> </td></tr>
</tbody>
</table>
</ItemTemplate>
</asp:Repeater>

</ItemTemplate>
</asp:Repeater>
        

       
   <table class="tb" id="tbS"><tr><td>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'m_id')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onclick="checkOthers('m_id')" />
   <input type="button" value="批量修改选中分类" class="btn" onclick="doPostEdit('','m_id')" id="Button1"/>&nbsp;&nbsp;&nbsp;移动到
   
    <select id="qcDp" style="width:150px">
           <% =QuestionClassDp()%>
    </select>
       <input class="btn" name="button" onclick="doPostMove('','m_id');" type="button" value="批量移动分类" /></td></tr></table>
    <table class="tb mt20" id="insertTb">
    <tr class="thead"><th colspan="8">添加分类</th></tr>	
        <tr align="center">
            <td width="305" align=left>
            选择层级：
                <select id="qcDp_add" style="width:150px" onchange="showCheck()">
                      <%=QuestionClassDp() %>
                </select>
          
            </td>
            <td  width="253">
                类别名：
              <input size="13" name="QuestionClassName" type="text" ><font color='red'>＊</font></td>
            <td  width="207" >
               <span id="IsConProduct_span" style="display:none">是否关联产品：
                <input name="IsConProduct"  type="checkbox" value="True" />
                </span></td>
            <td width="175"> 
        <input type="button" value="添 加"  class="btn" onclick="doPostInsert('')"/></td>
    </tr>
</table>
 <uc1:adminfoot ID="Adminfoot1" runat="server" />
    </div>   
</form>
<script type="text/javascript">   
    function  doPostEdit(url,sname)
    {    
        
        var ids=getIDList(sname);
        var Param='';       
        if(ids!="")
        {
            if((confirm("确定要批量修改这些记录?"))==true)
            {           
                   $("#loading").show();                   
                  for(var i=0;i<=ids.split(',').length-1;i++)
                  {  
                     var id=ids.split(',')[i];                                    
                     Param+= "&qcname"+id+"="+$("input[name='qcname"+id+"']").attr("value")+
                             "&qcfid"+id+"="+$("input[name='qcfid"+id+"']").attr("value")+
                             "&qs"+id+"="+document.getElementsByName("qs"+id)[0].checked;                                 
                  }  
                  url=url+"?action=editAll&id="+ids;                     
                  ajax_post(url,Param,function(msg){
                        $("#cpcontainer").empty().append(msg);
                        $("#loading").hide();
                  });
	        }
	    }
	    else
	    {
	        alert("您还没有选择要修改的项");
	        return;
	    }
    }    
    function doPostInsert(url)
    {    
        $("#loading").show();   
        var Datalist='';
        var qcid="";       
        qcid=document.getElementById("qcDp_add").options[document.getElementById("qcDp_add").selectedIndex].value;        
        url=url+"?action=Insert&id="+qcid;       
        var isConProduct=document.getElementsByName("IsConProduct")[0].checked;       
        Datalist+= "&questionclassname="+$("input[name=QuestionClassName]").attr("value")+
                   "&isConProduct="+isConProduct;                    
       ajax_post(url,Datalist,function(msg){
                if(msg=="1")
                {
                    alert("为题类别名称不能为空！");
                    $("#loading").hide();
                }
                else
                {
                     $("#cpcontainer").empty().append(msg);
                     $("#loading").hide();                     
                 }    
                })
    }    
    function doPostMove(url,sname)
    {
       
        var ids=getIDList(sname); 
        var fids="";
        for(var i=0;i<=ids.split(',').length-1;i++)
        {
            fids+=$("#qcf"+ids.split(',')[i]).attr("title");            
        }          
        if(ids!="")
        {
            var yidong="";
            var Param="";           
            yidong=document.getElementById("qcDp").options[document.getElementById("qcDp").selectedIndex].value;
            if((confirm("确定要移动这些记录?"))==true)
            { $("#loading").show();
                url=convertURL(url+"?action=MoveAll&id="+yidong+"&qcid="+ids+"&fids="+fids);             
                ajax_get(url,'',function(msg)
                {
                    if(msg=="1")
                    {
                        alert("目标类和移动类有重复，无法移动！");
                        $("#loading").hide();
                    }
                    else if(msg=="2")
                    {
                        alert("无法移动父类！");
                        $("#loading").hide();
                    }
                    else
                    {
                        $("#cpcontainer").empty().append(msg);
                        $("#loading").hide();
                    }
                    
                });
	        }
	    }
	    else
	    {
	        alert("您还没有选择移动项");	       
	        return false;
	    }
    }      
    function showCheck()
    {
        var checkValue=escape($("#qcDp_add :selected").attr("value"));
        if(checkValue!="0")
        {
           $("#IsConProduct_span").show();             
        }
        else
        {
            $("#IsConProduct_span").hide(); 
        }
    }  
    </script>
</body>
</html>
